﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ProjectEulerSolutions
{

    /*
     * Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.
     * (Problem13Input.txt)
     * */
    class Problem13
    {
        public static string Calculate()
        {
            string[] lines = new string[100];
            using (StreamReader sr = new StreamReader("Problem13Input.txt"))
            {
                for (int i = 0; i < 100; i++)
                    lines[i] = sr.ReadLine();
            }

            long sum = 0;

            //12 jer je maksimalan broj znamenki koji red moze dokucit 3 (9 * 100 = 900)
            for (int i = 0; i <= 12; i++)
            {
                for (int j = 0; j < lines.Length; j++)
                    sum += lines[j][i] - '0';

                sum *= 10;
            }

            int digits = (int)Math.Ceiling(Math.Log10(sum));

            sum =(long) (sum / Math.Pow(10, digits - 10));

            return sum.ToString();
        }
    }
}
